<#include "../common/base.ftl">
<@body>
        <div class="wu-toolbar-search" id="tb">
            <label>商品名称：</label><input class="wu-text" id="name" style="width:100px">
            <label>类型：</label><input class="wu-text" id="type" style="width:100px">
            <label>起始时间：</label><input id="startTime" class="easyui-datebox" style="width:100px" data-options="editable:false">
            <label>结束时间：</label><input id="endTime" class="easyui-datebox" style="width:100px" data-options="editable:false">
            <a class="easyui-linkbutton" iconCls="icon-search" onclick="find()">条件搜索</a>
        </div>
    <table id="tt" >
    </table>
    </@body>
    <@js>
    <script type="text/javascript">
    $(function(){
        $('#tt').datagrid({
            singleSelect:false,
            idField:'categoryId',
            rownumbers:true,
            toolbar: '#tb',
            pageSize:20,
            pagination:true,
            fitColumns:true,
            fit:true,
            method:'get',
            url:'/category/getData',
            columns:[[
                {field:'categoryId',title:'类别编号',width:60,algin: 'center'},
                {field:'categoryName',title:'类别名称',width:100,sortable:true,align: 'center'},
                {field:'categoryType',title:'类型',width:100,sortable:true,align: 'center'},
                {field:'createTime',title:'创建时间',width:80,align:'center'},
                {field:'action',title:'操作',width:70,align:'center',
                    formatter:function(value,row,index){
                        var e = '<a href="#" class="easyui-linkbutton" onclick="editrow(this)">编辑</a> ';
                        var d = '<a href="#" class="easyui-linkbutton" onclick="deleterow(this)">删除</a>';
                        return e+d;
                    }
                }
            ]]
        })
    });
    $(function () {
        $("#startTime").datebox("setValue", myformatter(getCurrentMonthFirst()));
        var curr_time = new Date();
        $("#endTime").datebox("setValue", myformatter(curr_time));
    });
    function deleterow(id) {
        alert(id);
    }

    function editrow(id) {
        alert(id)
    }
    function getCurrentMonthFirst() {
        var date = new Date();
        date.setDate(1);
        return date;
    }
    function myformatter(date) {
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        var d = date.getDate();
        return y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d);
    }
    function find() {
        $('#tt').datagrid('load',{
            reload:1,
            startTime:$('#startTime').datebox('getValue'),
            endTime:$('#endTime').datebox('getValue'),
            type:$('#type').val(),
            name:$('#name').val(),
        })
    }
</script>
    </@js>